from tool_func import get_or_none
from staff.models import StaffInfo
from weixin import userid_from_code

def get_user(request):
    empid = request.session.get('empid', '')
    if not empid:
        return None
    staff = get_or_none(StaffInfo, employee_id=empid)
    return staff


def login_in_weixin(request):
    abspath = request.META.get('host')+request.path
    url = weixin.embed_url(abspath)    
    return userid_from_code(code)
